/*
 * @Description  :
 * @Version      : 1.0
 * @Author       : Shiming
 * @Date         : 2021-12-03 15:31:52
 * @LastEditors  : Shiming
 * @LastEditTime : 2022-04-14 11:43:13
 * @FilePath     : \\tms-obc-web\\src\\app\\routes\\insurance-management\\services\\insurance-management.service.ts
 * Copyright (C) 2022 huzhenhong. All rights reserved.
 */

import { Injectable, Injector } from '@angular/core';
import { EACacheService, ShipperBaseService } from '@shared';
import { map } from 'rxjs/operators';

@Injectable({
  providedIn: 'root'
})
export class InsuranceManagementService extends ShipperBaseService {
  // 获取货主企业列表
  public $api_enterpriceList = '/api/mdc/cuc/enterpriseInfo/operate/enterpriceList';
  // 查询保险费信息表
  public $api_premiumInfo_list = '/api/sdc/premiumInfo/list/page';
  // 统计保险单状态数量
  public $api_listStatisticalStatus = '/api/sdc/premiumInfo/listStatisticalStatus';

  //  保险费公司认证
  $api_get_submitAuthInfo = `/api/sdc/premiumInfo/submitAuthInfo`;
  //  退保费
  $api_get_addINPBillRefundApplication = `/billRefundApplication/addINPBillRefundApplication`;
  //  保险费列表数据导出接口
  $api_get_asyncExport = `/api/sdc/premiumInfo/asyncExport`;

  public reviewPDF(url: string) {
    if (!url) {
      return;
    }
    this.openURL(url);
    // const uA = window.navigator.userAgent; // 判断浏览器内核
    // const isIE =
    //   /msie\s|trident\/|edge\//i.test(uA) &&
    //   !!('uniqueID' in document || 'documentMode' in document || 'ActiveXObject' in window || 'MSInputMethodContext' in window);
    // const objectUrl = url;
    // const a = document.createElement('a');
    // document.body.appendChild(a);
    // console.log('5555');

    // a.href = objectUrl;
    // a.download = '保单.pdf';
    // if (isIE) {
    //   // 兼容IE11无法触发下载的问题
    //   (navigator as any).msSaveBlob(url, a.download);
    // } else {
    //   a.click();
    // }
    // a.remove();
  }
  getReceiptUrl(url: string, params: any) {
    const { bankType, snglFlgCd } = params;
    if (url) {
      if (params?.bankType === '1') {
        window.open(params?.receiptUrl);
      } else if (params?.bankType === '2') {
        window.open(url);
        // this.exportFile({ bankType, receiptUrl: url, bankSerialNumber: snglFlgCd }, this.$api_download_receipt_apply_byte);
      }
    }
  }
  constructor(public injector: Injector) {
    super(injector);
  }
}
